home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr47 / asmlib40.zip / DATA2ASM.DOC < prev    next >
Text File  |  1995-03-30  |  3KB  |  106 lines

  1.  
  2.  
  3. DATA2ASM.COM
  4.  
  5. This is a simple program that converts a disk file to .ASM source
  6. so that you may incorporate the data in your programs.  This is handy
  7. for including character fonts, bitblocks or screens in your .EXE program.
  8.  
  9. Here's how you use it:
  10.  
  11. Let's assume you have a bitblock file called BITBLOCK.DAT, and you want
  12. to include this bitblock in your data segment:
  13.  
  14. C:\MYSUB>DATA2ASM IN=bitblock.dat OUT=bitblock.asm
  15.  
  16. This creates a file called BITBLOCK.ASM, which you may edit to add
  17. whatever public symbols you need.  If you were to assemble BITBLOCK.ASM,
  18. link and EXE2BIN, the resulting BITBLOCK.BIN would be an exact dupiclate
  19. of the original BITBLOCK.DAT; however, the real purpose of DATA2ASM is
  20. to add the output source file to your programs.  The example below grabs
  21. a bitblock from the screen and saves it as the file BITBLOCK.DAT.
  22.  
  23. include asm.inc
  24.  
  25. public  grab_and_write
  26. extrn   fcreate:proc, fput:proc, fclose:proc
  27. extrn    halloc:proc
  28. extrn    bitblockbytes:proc, getbitblock:proc
  29.  
  30. .data
  31. block_size dw ?
  32. blockptr   dw ?
  33. filename   db 'bitblock.dat',0
  34. x0         dw 10,10,100,100
  35.  
  36. .code
  37. grab_and_write    proc
  38.  
  39. ;
  40. ; this example program assumes that you have an image in the
  41. ; region defined by the corner coordinates at x0
  42. ;
  43. ; program fragment assumes DS:@data
  44. ;
  45.         .
  46.         .
  47.         lea   bx,x0         ; point to block corners
  48.         call  bitblockbytes ; calculate byte requirement
  49.         jc    too_big       ; error control
  50.         mov   block_size,ax ; save bytes
  51.         call  halloc        ; this example allocates the buffer from heap
  52.                             ; can't do this w/ huge bit blocks
  53.         jc    no_memory     ; more error control
  54.         mov   blockptr,bx        ; save near address of bit block
  55.         push  ds
  56.         pop   es            ; ES = DS
  57.         mov   di,bx         ; ES:[DI] points to buffer
  58.         lea   bx,x0         ; DS:[BX] points to coordinate data
  59.         call  getbitblock
  60.         lea   dx,filename   ; DS:[DX] points to filename
  61.         call  fcreate       ; create the file
  62.  
  63.         jc    something_went_wrong
  64.         mov   bx,ax         ; file handle to AX
  65.         mov   di,blockptr   ; ES:[DI] points to bitblock
  66.         mov   cx,block_size ; bytes to write
  67.         call  fput
  68.         jc    something_went_wrong
  69.         call  fclose
  70.         jc    something_went_wrong
  71.         ret                 ; back to caller
  72.  
  73. something_went_wrong:
  74. ;
  75. ; look up DOS error code, print message & quit
  76. ;
  77.         .
  78.         .
  79.         .
  80.         ret
  81.  
  82.  
  83. too_big:
  84. ;
  85. ; make up a lame excuse, then exit
  86. ;
  87.         .
  88.         .
  89.         .
  90.         ret
  91.  
  92. no_memory:
  93. ;
  94. ; print an error message, then exit
  95. ;
  96.         .
  97.         .
  98.         .
  99.         ret
  100. grab_and_write    endp
  101.  
  102.         end
  103.  
  104.  
  105. DATA2ASM source code is included with ASMLIB registration.
  106.